package top.stmo.springMVC.controller;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import top.stmo.springMVC.pojo.User;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 *       Rest 风格
 */
@Controller
@RequestMapping("qqqqqqqqqqqqqq")     //为了不冲突加上
public class UserRestController {

    //Rest 风格   新增/保存
    @ResponseBody
    @RequestMapping(value = "/users",method = RequestMethod.POST)
    public String save1() {
        System.out.println("users save");
        return "users save";
    }

    //Rest 风格   删除
    @ResponseBody
    @RequestMapping(value = "/users/{id}",method = RequestMethod.DELETE)
    public String delete(@PathVariable Integer id) {
        System.out.println("users delete");
        System.out.println(id);
        return "users delete";
    }

    //Rest 风格   修改
    @ResponseBody
    @RequestMapping(value = "/users",method = RequestMethod.PUT)
    public String update(@RequestBody User user) {
        System.out.println("users update");
        System.out.println("Users：" + user);
        return "users update";
    }

    //Rest 风格   单个查询
    @ResponseBody
    @RequestMapping(value = "/users/{id}",method = RequestMethod.GET)
    public String getById(@PathVariable Integer id) {
        System.out.println("users getById");
        System.out.println("Users：" + id);
        return "users getById";
    }

    //Rest 风格   查询所有
    @ResponseBody
    @RequestMapping(value = "/users",method = RequestMethod.GET)
    public String getAll() {
        System.out.println("user getAll");
        return "user getAll";
    }
}
